Attribute VB_Name = "Mouse32"
'Mouse32.bas made by axis of team indigo (c) 1998
'For 32 Visual Basic Programming
'http://fly.to/axis

'Usage:

'  If MouseIn(Image3) <> 0 Then
'      image3.picture = GlowingPic.Picture
'  Else
'      image3.picture = TheNormalPic.Picture
'  End If

'Notes:

'   This is a great bas for making interfaces,
' It's what I use to make all if my MouseOvers.
' It has a great advantage over MouseOver because
' it's a function and you can use IfElse statements
' instead of having tons of lines of code for resetting
' the non-mouseover.


Option Explicit

Type POINTAPI
        X As Long
        Y As Long
End Type


Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long


Function MouseIn(acntl As Control) As Integer
Dim apoint As POINTAPI
Dim saveformmode As Integer
Dim savecntlmode As Integer
Dim Xoffset As Integer
Dim Yoffset As Integer
Dim borderwidth As Integer
Dim titleheight As Integer
Dim pixx As Integer, PixY As Integer
Dim Aform As Form

Set Aform = acntl.Parent
On Error Resume Next
MouseIn = False

GetCursorPos apoint

saveformmode = Aform.ScaleMode
savecntlmode = acntl.ScaleMode

Aform.ScaleMode = 3
acntl.ScaleMode = 3

pixx = Screen.TwipsPerPixelX
PixY = Screen.TwipsPerPixelY

borderwidth = ((Aform.Width / pixx) - Aform.ScaleWidth) \ 2
titleheight = (Aform.Height / PixY) - Aform.ScaleHeight - (borderwidth * 2)

Xoffset = (Aform.Left / pixx) + borderwidth + acntl.Left
Yoffset = (Aform.Top / PixY) + borderwidth + titleheight + acntl.Top

If (apoint.X > Xoffset) And (apoint.X < (Xoffset + acntl.Width)) Then
    If (apoint.Y > Yoffset) And (apoint.Y < (Yoffset + acntl.Height)) Then
    MouseIn = True
    End If
End If

Aform.ScaleWidth = saveformmode
acntl.ScaleMode = savecntlmode
End Function

